#include "bank.h"
#include <cstdio>
#include <locale>

class Base {
public:
  virtual ~Base() = default;
};
class Derived : public Base {
public:
  Derived() { printf("Derived() invoked\n"); }
  ~Derived() { printf("~Derived() invoked\n"); }
};

void example() {
  printf("Constructing Derived object...\n");
  Base *d{new Derived{}};
  printf("Deleting d as Base*\n");
  delete d;
}

void belongToUs(Base &base) {}

void useDerivedRef() {
  Derived d;
  belongToUs(d);
}

void useBank();

int main(int argc, char *argv[]) {
  printf("==== ch05 p03 ====\n");
  printf("---- example() ----\n");
  example();
  printf("---- useBank() ----\n");
  useBank();
  return 0;
}

/*
void useBank() {
  FileLogger fileLogger;
  Bank bank{fileLogger};
  bank.makeTransfer(1000, 2000, 44.5);
  bank.makeTransfer(2000, 3000, 33.5);
}
*/

void useBank() {
  ConsoleLogger consoleLogger;
  FileLogger fileLogger;
  Bank bank{&fileLogger};
  bank.makeTransfer(1000, 2000, 44.5);
  bank.setLogger(&consoleLogger);
  bank.makeTransfer(2000, 3000, 33.5);
}
